import Vue from "vue";

Vue.filter("cutstr", (str: string, len: number, tip: string) => {
  if (!str) return "";
  console.log(str, len, tip);
  if (str.length < len) return str;
  return str.substring(0, len) + tip;
});

Vue.filter("percent", (val: number) => Math.round(val * 100) / 100);

Vue.filter("num2px", (val: string) => {
  if (val.indexOf("px") == -1) return `${val}px`;
  return val;
});
